package com.itheima.manager.StudentDao;

import com.itheima.manager.Student.Student;

public class StudentDao {
    private static Student[] stus = new Student[5];
    public Student[] findAllStudent() {
      return stus;
    }

    public void addStudent(Student stu) {
        int index = -1;
        for (int i = 0; i < stus.length; i++) {
            Student students =stus[i];
            if (stus[i]==null){
                index=i;
                break;
            }
        }
        if (index!=-1){
            stus[index]=stu;
        }
    }
    public void deletStudent(String id) {
        for (int i = 0; i < stus.length; i++) {
            Student students = stus[i];
            if (stus[i] != null&&students.getId().equals(id)){
                stus[i] = null;
            }
            break;
        }
    }

    public void updateStudent(Student stu) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i]!=null&&stus[i].getId().equals(stu.getId())){
                stus[i]=stu;
                break;
            }
        }
    }
}
